#include<iostream>
#include<functional>

class BB{
public:
    BB() = default;
	std::function<int(int)> callback_;
	void setNotifer(std::function<int(int)> callback){
		 callback_ = callback;
	}
};

class AA{
public:
    BB bb_;
    AA() = default;
    AA(BB &bb)
    {
        bb_ = bb;
    }
	class add
    {
    public:
        add() = default;
        int operator()(int x)
        {
            return x + 9;
        }
    };
    void init()
    {
        bb_.setNotifer(AA::add());
    }
};


int main(int argc, char *argv[])
{   BB bb;
    AA aa(bb);
    aa.init();
    //std::function包装对象函数
    std::cout << aa.bb_.callback_(11) << std::endl; //std::function对象实例调用包装的调用实体
    return 0;
}
